# -*- coding: UTF-8 -*-
"""
@version: 1.0
@PackageName: GUI_TEST - start_connect_test.py
@author: beixun
@Description: 
@since 2025/11/12 15:09
"""
import time

from pywinauto import Application

# 启动对应的程序,使用绝对路径,启动就是已经链接(connect)成功
app = Application(backend="uia").start("C:\\Program Files\\Notepad++\\notepad++.exe")
# 输出程序的进程id
print(app.process)

time.sleep(3)

# 链接对应的程序进程
#Application(backend="uia").connect(process=app.process)
print("------------------------------------------------")
# 链接其他进程,使用进程id
Application(backend="uia").connect(process=14256)

# 链接其他进程,使用handle(句柄)
print("------------------------------------------------")
#Application(backend="uia").connect(handle=)